<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        //test
        const deque = new Deque();
        /*      const deque = new Deque();
            deque.addBack("john");
            deque.addBack("jack");
            deque.addFront("camila");
            console.log(deque.toString());
            console.log(deque.removeBack());
            console.log(deque.removeBack()); */

        function palindromeChecker(aString) {
            if (aString === undefined || aString === null ||
                (aString != null && aString.length === 0)) {
                return false;
            }
            const deque = new Deque();
            const lowerString = aString.toLocaleLowerCase().split(" ").join("");
            let isEqual = true;
            let firstChar, lastChar;
            for (let i = 0; i < lowerString.length; i++) {
                deque.addBack(lowerString.charAt(i));
            }

            while (deque.size() > 1 && isEqual) {
                firstChar = deque.removeFront();
                lastChar = deque.removeBack();
                if (firstChar != lastChar) {
                    isEqual = false;
                }
            }

            return isEqual;




        }
        let strs = ["a", "aba", "ade", "hello", "this is a test", "aka aka"];
        let str;
        for (let i = 0; i < strs.length; i++) {
            str = strs[i];
            console.log(str, palindromeChecker(str));
        }
    </script>
</body>

</html>